#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,V,d[100100],v[100100],a[100100],p[100100],num,k,numc;
//double l[100100],r[100100];
int cl[100100],cr[100100],ans,ne[100100];
bool b[100100],f[100100],op[100100];
vector<int>cp[100100];
vector<int>ti[100100];
struct Da
{
    double l,r;
}c[100100];
bool cmp(Da A,Da B)
{
    if(A.l!=B.l)return A.l<B.l;
    return A.r<B.r;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)
    {
        //cout<<T<<"::::"<<endl;
        memset(c,0,sizeof(c));
        memset(d,0,sizeof(d));
        memset(b,0,sizeof(b));
        memset(f,0,sizeof(f));
        memset(ti,0,sizeof(ti));
        memset(op,0,sizeof(op));
        memset(cl,0,sizeof(cl));
        memset(cp,0,sizeof(cp));
        memset(cr,0,sizeof(cr));
        memset(ne,0,sizeof(ne));
        ans=0;
        num=0;
        ans=0;
        k=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)
        {
            //cout<<i<<"::"<<k<<endl;
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]==0)
            {
                if(v[i]>V)
                {
                    c[++k].l=d[i];
                    c[k].r=L;
                    //cout<<"::";
                }
            }
            if(a[i]<0)
            {
                if(v[i]<=V)continue;
                else
                {
                    double t=1.0*(V*V-v[i]*v[i])/(2*a[i]);
                    c[++k].l=d[i];
                    c[k].r=min(1.0*L,d[i]+t);
                   // cout<<"??";
                }
            }
            if(a[i]>0)
            {
                if(v[i]>=V)
                {
                    c[++k].l=d[i];
                    c[k].r=L;
                    continue;
                }
                double t=1.0*(V*V-v[i]*v[i])/(2*a[i]);
                if(t>L)continue;
                c[++k].l=t+d[i];
                c[k].r=L;
                //cout<<"..";
            }
        }
        sort(c+1,c+k+1,cmp);
        //for(int i=1;i<=n;i++)
        //{
         //   cout<<c[i].l<<" "<<c[i].r<<" "<<d[i]<<" "<<v[i]<<" "<<a[i]<<endl;
        //}

        ans=0;
        //cout<<k<<"::";
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
            cl[i]=0x3f3f3f3f;
            cp[i].push_back(0);
            //cout<<i<<"??????????????"<<la<<endl;
            for(int j=1
                ;j<=k;j++)
            {
             //   cout<<c[j].l<<":"<<p[i]<<"?"<<c[j].r<<" "<<i<<" "<<j<<endl;
                //if(c[j].l<=p[i])la=j;
                if(c[j].l<=p[i]&&p[i]<=c[j].r)
                {
                    //cout<<":::\n";
                    cp[i].push_back(j);
                    cp[i][0]++;
                    ti[j].push_back(i);
                    cl[i]=min(cl[i],j);
                    cr[i]=max(cr[i],j);
                    if(!b[j])
                    {
                        ans++;
                    }
                    b[j]=true;
                }
               // if(p[i]<c[j].l)break;
            }
        }
        //cout<<k<<":::";
        //for(int i=1;i<=k;i++)cout<<b[i]<<" ";cout<<endl;
        //for(int i=1;i<=m;i++)cout<<cl[i]<<" "<<cr[i]<<endl;cout<<endl;
        //for(int i=1;i<=m;i++)
       // {
         //   for(int j=0;j<ti[i].size();j++)
         //   {
         //       cout<<ti[i][j]<<" ";
        //    }cout<<endl;
       // }cout<<endl;
       // for(int i=1;i<=m;i++)
       // {
        //    for(int j=1;j<cp[i].size();j++)
        //    {
         //       cout<<cp[i][j]<<" ";
        //    }cout<<endl;
       // }cout<<endl;
        cout<<ans<<" ";
        if(ans==0)
        {
            cout<<m<<endl;
            continue;
        }
        for(int i=k;i>=1;i--)
        {
            if(b[i])numc=i;
            break;
        }
        ne[n]=k+1;
       for(int i=i-1;i>=0;i--)
        {
            if(b[i+1])ne[i]=i+1;
            else ne[i]=ne[i+1];
        }
        //for(int i=0;i<=k;i++)cout<<ne[i]<<" ";cout<<endl;
        int nowl=0,dai=0,dair=0,num=0,Q=0;
        //cout<<0<<" "<<dai<<" "<<dair<<" "<<nowl<<endl;
        for(int i=1;i<=m;i++)
        {
            if(f[i]||!b[i])continue;
            int maxl=-1,maxn;
            for(int j=0;j<ti[i].size();j++)
            {

                if(cp[ti[i][j]][0]>maxl&&!op[ti[i][j]])
                {
                    maxl=cp[ti[i][j]][0];
                    maxn=ti[i][j];
          //          cout<<op[maxn]<<":";
                }
            }
            //cout<<i<<" "<<maxn<<"     ??"<<op[maxn]<<"???";
            op[maxn]=true;
           for(int j=1;j<cp[maxn].size();j++)
            {
                int cap=cp[maxn][j];
                //cout<<cap<<":::";
                if(!f[cap])num++;
                f[cap]=true;
                for(int k=0;k<ti[cap].size();k++)
                {
                    cp[ti[cap][k]][0]--;
                }
            }
            Q++;
           // for(int j=1;j<=k;j++)cout<<f[j]<<":";cout<<endl;
            if(num==ans)break;
        }
        //if(nowl!=numc)num++;
       // cout<<m<<" "<<Q<<endl;
        cout<<m-Q<<endl;
    }
    return 0;
}
